
var forms = {
	
	load: function(){
		$('form').unbind();
		$('form').submit(function(event){
			event.preventDefault();
			var action = this.action;
			action = action.substr(action.lastIndexOf('/')+1);
			var field = new forms.field(this);
			var params = field.getAll();
			ws.send(action, params);
		});
	},
	
	field: function(form){
		this.form = form;
		this.get = function(field){
			return $(this.form.elements[field]).val();
		}
		this.getAll = function(){
			var fields = {};
			elems = this.form.elements;
			for(var i = 0; i < elems.length; i++)
				fields[elems[i].name] = $(elems[i]).val();
			return fields;
		}
	}
}